package com.lyc.service.Impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.lyc.dao.GouDao;
import com.lyc.pojo.Cart;
import com.lyc.pojo.Goods;
import com.lyc.service.GouService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
@Service("gouService")
public class GouServiceImpl implements GouService {
    @Autowired
    private GouDao gouDao;
    @Override
    public List<Cart> select(int uid) {
        return gouDao.select(uid);
    }

    @Override
    public List<Cart> updateone(int num, int scid,int uid) {
         gouDao.updateone(num,scid);
        return gouDao.select(uid);
    }

    @Override
    public List<Goods> getAllGoodsByUid(int uid) {
        return gouDao.getAllGoodsByUid(uid);
    }

    @Override//查询当前用户购物车是否存有该商品
    public Cart selectCart(int gid, int uid) {
        return gouDao.selectGoods(gid,uid);
    }

    @Override
    public void addGoods(Cart cart) {
        gouDao.addGoods(cart);
    }

    @Override
    public int removeByScid(int scid) {
        return gouDao.removeByScid(scid);
    }

    /*后台*/
    @Override
    public PageInfo<Cart> getGoByPage(Integer page, Integer limit) {
        PageHelper.startPage(page,limit);
        List<Cart> carts=gouDao.selectAll();
        return new PageInfo<>(carts);
    }

    @Override
    public List<Cart> selectAll() {
        return gouDao.selectAll();
    }


}
